package com.example.util

import android.content.Context
import android.view.View
import android.view.inputmethod.InputMethodManager

/**
 * 键盘工具类
 * @author  chaohaipeng  on 2018/7/12.
 */
/**
 * 关闭输入法
 */
fun closeInput(context: Context?, view: View?) {
    val inputManager = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
    val isOpen = inputManager.isActive
    if (isOpen) {
        inputManager.hideSoftInputFromWindow(view?.windowToken, InputMethodManager.HIDE_NOT_ALWAYS)
    }
}